﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace Code
{
    public class StatisticDataAccess
    {
        protected DataProvider _provider = DataProvider.GlobalDataProvider;

        public DataTable GetYearList()
        {
            string strSQL = string.Format("Select Distinct Year(NgayXacNhan) From HOA_DON");
            return _provider.ExecuteQueryDataTable(strSQL);
        }

        public DataTable GetMonthList(int year)
        {
            string strSQL = string.Format("Select Distinct Month(NgayXacNhan) From HOA_DON Where Year(NgayXacNhan) = {0}",year);
            return _provider.ExecuteQueryDataTable(strSQL);
        }

        public DataTable GetStatisticWithMonth(int month, int year)
        {
            string strSQL = string.Format("Select Sum(TongTien) From HOA_DON Where Month(NgayXacNhan) = {0} and Year(NgayXacNhan) = {1}", month, year);
            return _provider.ExecuteQueryDataTable(strSQL);
        }
    }
}
